package com.peycard.persistence.dao;

import javax.ejb.Stateless;
import javax.persistence.Query;

import com.peycard.common.util.Constantes;
import com.peycard.persistence.PersistenceException;
import com.peycard.persistence.dao.local.CatalogProcessingCodeDAOLocal;
import com.peycard.persistence.entities.CatalogProcessingCode;

/**
 * Session Bean implementation class CatalogProcessingCodeDAO
 */
@Stateless
public class CatalogProcessingCodeDAO extends
		GenericDAOImpl<CatalogProcessingCode, Long> implements
		CatalogProcessingCodeDAOLocal {

	/**
	 * Default constructor.
	 */
	public CatalogProcessingCodeDAO() {
		// TODO Auto-generated constructor stub
	}
	
	

	@Override
	public CatalogProcessingCode getCatalogProcessingCodeExtended(Long id)
			throws PersistenceException {
		try {
			Query query = getEntityManager().createNamedQuery("findCPCWithCPP");
			query.setParameter("id", id);
			CatalogProcessingCode cpc = (CatalogProcessingCode) query
					.getSingleResult();
			return cpc;
		} catch (Exception ex) {
			throw new PersistenceException(
					Constantes.ERROR_ENTITY_NOT_FOUND_ERROR, ex);
		}

	}

}
